package cn.agiledata.bank.common.service.email;

import java.util.Date;
import java.util.Map;

import cn.agiledata.bank.common.dao.ActionTypeTemplate;
import cn.agiledata.bank.common.service.NotifyMail;
import cn.agiledata.bank.common.util.DateUtil;
import cn.agiledata.bank.common.util.WeatherUtil;
import cn.agiledata.bank.hibernateBean.AccountBank;
import cn.agiledata.bank.hibernateBean.BankInfo;
import cn.agiledata.bank.hibernateBean.ScoresHis;
import cn.agiledata.bank.hibernateBean.SubAccount;
import cn.agiledata.bank.hibernateBean.Transaction;
import cn.agiledata.bank.myspace.dao.IMySpaceDao;
import com.vnv.infrastructure.logic.IPBAppFactory;

/**
 * @author 马贤波
 *
 */
public class BankCardMail extends NotifyMail {
	private AccountBank ab ;
	private String titlemessage;
	private IMySpaceDao mySpaceDao;
	public AccountBank getAb() {
		return ab;
	}

	public void setAb(AccountBank ab) {
		this.ab = ab;
	}
	
	public String getTitlemessage() {
		return titlemessage;
	}

	public void setTitlemessage(String titlemessage) {
		this.titlemessage = titlemessage;
	}

	public IMySpaceDao getMySpaceDao() {
		return mySpaceDao;
	}

	public void setMySpaceDao(IMySpaceDao mySpaceDao) {
		this.mySpaceDao = mySpaceDao;
	}

	protected SubAccount setMailContext(Map vnvMap, Transaction tran,
			ScoresHis score) {
		AccountBank ab = getAb();
		String now = DateUtil.date2String(new Date());
		String number ="";
		if(ab.getAccountId().length()>4)
			number = new StringBuffer(ab.getAccountId()).substring(ab.getAccountId().length()-4).toString();
		else
			number = ab.getAccountId();
		String type = ab.getCardType();
		String cardtype = getMySpaceDao().getCardType(type);
		String bankName = ab.getBankInfo().getBankName();
		vnvMap.put("bank", bankName);//所属银行
		vnvMap.put("accountName", ab.getAccountName());//开户人姓名
		vnvMap.put("accountBank", ab.getAccountBank());//
		vnvMap.put("bankName", ab.getBankName());//开户银行名称
		vnvMap.put("accountId", ab.getAccountId());
		vnvMap.put("bankAlias", ab.getBankAlias());//银行卡名称
		vnvMap.put("titlemessage", getTitlemessage());
		vnvMap.put("name", WeatherUtil.getNameOrEmailOrMobileByAccount(ab.getAccount()));
		vnvMap.put("cardtype", cardtype);
		vnvMap.put("time", now);
		vnvMap.put("cardNumber", number);
		vnvMap.put("accountId","********"+number);
		return ab.getAccount().getDefaultSubAccount();
	}

}
